﻿using System;
using System.ServiceModel;
using System.Data.Entity;
using Domep.Server.Services;
using Domep.Server.Services.Kernel.DBCommunication;

namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {

            ServiceHost appliancePresentationManagerHost = new ServiceHost(typeof(AppliancePresentationManager));
            Console.WriteLine("Lancement du serveur...");
            Console.WriteLine("Démarrage des services...");
            appliancePresentationManagerHost.Open();
            
            PrepareDB();
            Console.WriteLine("Mise à jour de la base de données...");
            Console.WriteLine("Serveur prêt. Presser 'Entrer' pour quitter...");
            Console.ReadLine();
            appliancePresentationManagerHost.Close();
        }

        private static void PrepareDB()
        {
            Database.SetInitializer<ServerContext>(new ServerContextInitializer());
        }
    }
}
